import request from '@utils/request'
// 请求分类
const fetchCates = (params = {}) => request.get('/shop/goods/category/all', { params })
// 请求轮播图
const fetchBanner = (params = {}) => request.get('/banner/list', { params })
// 请求商品
const fetchItems = (params = {}) => request.post('/shop/goods/list/v2', params)
// 请求商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', { params: { id } })
// 请求注册
const register = (params = {}) => request.post('/user/username/register', params)
// 用户登录
const doLogin = (params = {}) => request.post('/user/username/login', params)
// 请求加入购物车接口
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 读取购物车数据
const itemCart = (params = {}) => request.get('/shopping-cart/info', { params })
// 修改购物车商品数量
const changeCartNumber = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 删除购物车商品
const removeCart = (params = {}) => request.post('/shopping-cart/remove', params)
// 修改商品选中状态
const selectCart = (params = {}) => request.post('/shopping-cart/select', params)
// 添加收货联系人
const addContact = (params = {}) => request.post('/user/shipping-address/add', params)
// 收货人列表
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2', params)
// 更新收货人信息
const updateContact = (params = {}) => request.post('/user/shipping-address/update', params)
// 获取收货人的详情
const fetchContactInfo = (params = {}) => request.get('/user/shipping-address/detail/v2', {
  params
})
// 获取默认联系人
const fetchDefaultContact = (params = {}) => request.get('/user/shipping-address/default/v2', {
  params
})
// 删除联系人
const detelContact = (params = {}) => request.post('/user/shipping-address/delete', params)
export {
  fetchCates,
  fetchBanner,
  fetchItems,
  fetchDetail,
  addCart,
  register,
  doLogin,
  itemCart,
  changeCartNumber,
  removeCart,
  selectCart,
  addContact,
  fetchContacts,
  updateContact,
  fetchContactInfo,
  fetchDefaultContact,
  detelContact
}
